package com.macro.mall.controller;

import com.macro.mall.common.api.CommonPage;
import com.macro.mall.common.api.CommonResult;
import com.macro.mall.dto.UmsMemberAddressAddUsername;
import com.macro.mall.dto.UmsMemberAddressQueryParam;
import com.macro.mall.service.UmsMemberReceiveAddressService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 订单管理Controller
 * Created by P7 on 2021/4/21.
 */
@Controller
@Api(tags = "UmsMemberReceiveAddressController", description = "地址管理")
@RequestMapping("/address")
public class UmsMemberReceiveAddressController {
    @Autowired
    private UmsMemberReceiveAddressService addressService;

    @ApiOperation("查询地址")
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult<CommonPage<UmsMemberAddressAddUsername>> list(UmsMemberAddressQueryParam queryParam,
                                                                      @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
                                                                      @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
        List<UmsMemberAddressAddUsername> addressList = addressService.list(queryParam, pageSize, pageNum);
        return CommonResult.success(CommonPage.restPage(addressList));
    }
}
